package com.config;

import java.util.Map;
import java.util.Properties;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.web.context.support.StandardServletEnvironment;

@Configuration
@PropertySource("classpath:mq-busihandler.properties")
public class MQBusiHandler 
{
	@Autowired
	private Environment env;
	
	private Properties props;
	
	@SuppressWarnings("unchecked")
	@Bean
	public Properties getMqHandlerProp() throws Exception 
	{
		StandardServletEnvironment e = (StandardServletEnvironment)env;
		MutablePropertySources propertySources = e.getPropertySources();
		org.springframework.core.env.PropertySource<?> propertySource = propertySources.get("class path resource [mq-busihandler.properties]");
		Map<String, String> appMap = (Map<String, String>) propertySource.getSource();
		props = new Properties();
		for(String key:appMap.keySet())
		{
			props.put(key, appMap.get(key));
		}
		return props;
	}

	public Properties getProps() {
		return props;
	}

	public void setProps(Properties props) {
		this.props = props;
	}
}
